﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Dm;

namespace OneClick
{
    public partial class 二级代码 : Form
    {
        static DmConnection cnn = new DmConnection();
        public 二级代码()
        {
            InitializeComponent();
        }

        private void 二级代码_Load(object sender, EventArgs e)
        {
            cnn.ConnectionString = Form1.sstr;
            string COL = Form1.Clo;
            string sql2 = "select AAA102, AAA103 from hnsimis.aA10 where aaa100 = trim(upper('" + COL.Replace('\t', ' ') + "'))";
            cnn.Open();
            DmCommand command = new DmCommand();
            command.Connection = cnn;
            try
            {
                string a;
                string b;
                command.CommandText = sql2;
                DmDataReader reader = command.ExecuteReader();
                //foreach (string item in listBox2.Items) //错误的用法
                //{
                //    listBox2.Items.Remove(item);
                //}
                while (listBox1.Items.Count > 0)
                {
                    listBox1.Items.Remove(listBox1.Items[0]);
                }
                while (reader.Read())
                {
                    a = reader.GetString(0);
                    b = reader.GetString(1);
                    listBox1.Items.Add(a + "\t" + b); ;
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                //label1.Text = (ex.Message);
            }
            cnn.Close();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
